﻿
$(function(){
	var pathName=window.document.location.pathname;
	var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
	
	$('#wordSexNamets').hide();
	
	$('#wordSexName').on('change', function() {
		var wordSexNameValue = $('#wordSexName').val();
		if(wordSexNameValue == "") {
			$('#wordSexNamets').hide();
			$('#submitButton').attr('disabled', 'disabled');
		} else {
			$.ajax({
				url:projectName + "/WordSex/haveSameWordSexName",
				type:"post",
				async:true,
				data:{"wordSexName" : wordSexNameValue},
				success:function (data) {
					if(data == "yes") {
						$('#wordSexNamets').show();
						$('#submitButton').attr("disabled",'disabled');
					} else {
						$('#wordSexNamets').hide();
						$('#submitButton').removeAttr('disabled');
					}
				}
			});
		}
	});
});